package com.blacksee.bluetoothpoker.network.messages;

import com.blacksee.bluetoothpoker.logic.net.mypapit.java.StringTokenizer;

public class AcceptanceResponseMessage implements NetMessage {

	private boolean isAccepted;
	
	private String acceptedName;
	
	private int    acceptedId;
	
	public AcceptanceResponseMessage(boolean isAccepted, String acceptedName,
			int acceptedId) {
		super();
		this.isAccepted = isAccepted;
		this.acceptedName = acceptedName;
		this.acceptedId = acceptedId;
	}

	public String getAcceptedName() {
		return acceptedName;
	}

	public void setAcceptedName(String acceptedName) {
		this.acceptedName = acceptedName;
	}

	public int getAcceptedId() {
		return acceptedId;
	}

	public void setAcceptedId(int acceptedId) {
		this.acceptedId = acceptedId;
	}

	public AcceptanceResponseMessage(boolean isAccepted){
		this.isAccepted = isAccepted; //allways accepted
	}
	
	public int getSenderID() {
		return 0;
	}
	
	public boolean isAccepted(){
		return isAccepted;
	}

	public void parseParameters(String message) {
		StringTokenizer tok = new StringTokenizer(message);
		String messageHead = tok.nextToken("*");
		
		//msg format: "ACCEPTANCE_RESPONSE*acceptedId*acceptedName"
		this.acceptedId = Integer.parseInt(tok.nextToken("*"));
		this.acceptedName = tok.nextToken();	
		
	}

	public String GetMessageString() {
		String text = "ACCEPTANCE_RESPONSE*" + this.acceptedId +"*"+ this.acceptedName;
		return text;
	}

}
